package com.heihei.security.init;

import com.heihei.security.config.ApplicationConfig;
import com.heihei.security.config.WebConfig;
import com.heihei.security.config.WebSecurityConfig;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

/**
 * Spring容器 初始化类   （此类实现了WebApplicationInitializer接口，Spring容器启动时会加载WebApplicationInitializer的所有实现类）
 *
 * @author duanhengfei
 * @version 1.0
 * @date 2020/6/26 22:02
 * @since JDK1.8
 */
public class SpringApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
    //Spring容器，相当于加载 applicationContext.xml
    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class<?>[] {ApplicationConfig.class, WebSecurityConfig.class};  //指定rootContext的配置类
    }

    //servletContext， 相当于加载 springmvc.xml
    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class<?>[] {WebConfig.class};  //指定ServletContext的配置类
    }

    //url-mapping
    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }
}